package com.jk.vehicle.mini.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.jk.vehicle.mini.service.UserBicycleLinkService;
import com.jk.vehicle.mini.dao.UserBicycleLinkMapper;
import com.jk.vehicle.mini.entity.UserBicycleLink;
import com.jk.vehicle.core.service.impl.AbstractService;
import com.jk.vehicle.mini.util.QueryUtil;
import com.jk.vehicle.mini.util.SequenceUtils;
import com.jk.vehicle.mini.vo.UserBicycleLinkVO;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Condition;
import tk.mybatis.mapper.entity.EntityColumn;
import tk.mybatis.mapper.entity.Example;
import tk.mybatis.mapper.mapperhelper.EntityHelper;

import javax.annotation.Resource;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * This is Description for UserBicycleLinkServiceImpl
 *
 * @author Administrator
 * @date 2021/02/08
 */
@Service
public class UserBicycleLinkServiceImpl extends AbstractService<UserBicycleLink> implements UserBicycleLinkService {
    /**
	 * 注入UserBicycleLinkMapper
	 */
    @Resource
    private UserBicycleLinkMapper userBicycleLinkMapper;

    /**
    * 根据查询条件查询单表数据
    * @param paramMap 查询条件
    * @return 查询结果
    */
    public List<UserBicycleLink> queryByParams(Map<String, Object> paramMap){
        Condition condition = new Condition(UserBicycleLink.class);
        Example.Criteria criteria = condition.createCriteria();
        Map<String, EntityColumn> propertyMap = EntityHelper.getEntityTable(UserBicycleLink.class).getPropertyMap();
        QueryUtil.spliceQueryParam(criteria, paramMap,  propertyMap, condition);
        return userBicycleLinkMapper.selectByCondition(condition);
    }

    /**
     * 查询车辆分享关联信息
     * @param bicycleId 车辆ID
     * @return 结果
     */
    @Override
    @DS("#last")
    public List<UserBicycleLinkVO> queryShareLinkData(Long bicycleId, String dsName){
        return userBicycleLinkMapper.queryShareLinkData(bicycleId);
    }

    /**
     * 根据用户id查询用户车辆关联列表
      * @param userId
     * @return
     */
    @Override
    public List<UserBicycleLink> queryUserBicycleLinkCommonCorpById(Long userId) {
        return userBicycleLinkMapper.queryUserBicycleLinkCommonCorpById(userId);
    }

    /**
     * 根据用户id分组查询用户车辆关联列表
     * @param userId
     * @return
     */
    @Override
    public List<UserBicycleLink> queryUserBicycleLinkCorpById(Long userId) {
        return userBicycleLinkMapper.queryUserBicycleLinkCorpById(userId);
    }

    @Override
    @DS("#last")
    public void save(UserBicycleLink userBicycleLink, String dsName) {
        super.save(userBicycleLink, dsName);
    }

    @Override
    @DS("#last")
    public void update(UserBicycleLink userBicycleLink, String dsName){
        super.update(userBicycleLink, dsName);
    }
}
